#ifndef MATH_FIXED_POINT_H
#define MATH_FIXED_POINT_H

typedef unsigned char Fixed8;
typedef unsigned short Fixed16;
typedef unsigned int Fixed32;

#include <windows.h>

namespace Fixed_24_8
{
	static Fixed32 One = (1 << 8);
	inline Fixed32 FromInt(unsigned int a) { return a << 8; }
	inline Fixed32 FromDouble(double a) { return (Fixed32)(a*256.0 + 0.5); }
	inline unsigned int ToInt(Fixed32 a) { return a >> 8; }
	inline double ToDouble(Fixed32 a) { return double(a)/256.0; }
	inline Fixed32 Add(Fixed32 a, Fixed32 b) { return a+b; }
	inline Fixed32 Sub(Fixed32 a, Fixed32 b) { return a-b; }
	inline Fixed32 Mul(Fixed32 a, Fixed32 b) { return (a>>4)*(b>>4);
		return MulDiv(a,b,One);
	}
	inline Fixed32 Div(Fixed32 a, Fixed32 b) { 
		return MulDiv(One,a,b);
	}
};

#endif
